using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Navigation;
using Microsoft.SharePoint.Administration;
using System.Diagnostics;

namespace Gucci.DbTaglio.Site.Features.DbTaglioWebElements
{

    [Guid("bc099920-0ff7-4d0e-880a-8187038f2fe3")]
    public class DbTaglioWebElementsEventReceiver : SPFeatureReceiver
    {

      
        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {

            SPSite siteCollection = (SPSite)properties.Feature.Parent;
            SPWeb site = siteCollection.RootWeb;


            SPFolder SitePages = site.GetFolder("DbTaglioWebElements");
            if (SitePages.Exists)
            {
                SitePages.Delete();
            }

            SPNavigationNodeCollection topNav = site.Navigation.TopNavigationBar;
            for (int i = (topNav.Count - 1); i >= 0; i--)
            {
                if (topNav[i].Url.Contains("DbTaglioWebElements"))
                {
                    topNav[i].Delete();
                }
            }


        }//fM


        // Uncomment the method below to handle the event raised after a feature has been installed.

        //public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        //{
        //}


        // Uncomment the method below to handle the event raised before a feature is uninstalled.

        //public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        //{
        //}

        // Uncomment the method below to handle the event raised when a feature is upgrading.

        //public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters)
        //{
        //}
    }
}
